//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "fn_checkActionFirstAid.sqf"
#include <btc_macros.h>
TRACE_1("Start",_this);

private ["_debug","_injured","_array_item_injured"];
DEFAULT_PARAM(_debug,0,false);
_cond = false;
_array_item = items player;
_men = nearestObjects [vehicle player, ["Man"], 2];
if (_debug) then { TLOG_1("_men",_men); };
if (count _men > 1 && format ["%1", player getVariable ["BTC_need_revive",0]] == "0") then
{
	if (format ["%1", (_men select 1) getVariable ["BTC_need_revive",0]] == "1" && !BTCR_dragging && format ["%1", (_men select 1) getVariable ["BTCR_dragged",0]] == "0") then {
		TRACE("Condition 1");
		_cond = true;
	};
	_injured = _men select 1;
};
if (_cond && BTC_pvp == 1) then 
{
	if ((_men select 1) getVariable "BTC_revive_side" == str (BTC_side)) then {_cond = true;} else {_cond = false;};
	TRACE("Condition 2");
};
if (_cond && BTC_need_first_aid == 1) then
{
	if (_array_item find "FirstAidKit" == -1 && _array_item find "Medikit" == -1) then {_cond = false;};
	_array_item_injured = items _injured;
	if (!_cond && (_array_item_injured find "FirstAidKit" != -1 || _array_item_injured find "Medikit" != -1)) then {_cond = true;};
};
TRACE_1("_cond",_cond);
_cond
